package net.ch2.pc12.tech.ackborn.activity.thread;

import java.util.List;

import net.ch2.pc12.tech.ackborn.R;
import net.ch2.pc12.tech.ackborn.activity.ThreadActivity;
import net.ch2.pc12.tech.ackborn.dto.ProgressDTO;
import net.ch2.pc12.tech.ackborn.model.BbsArticleModel;
import android.content.Context;
import android.os.Handler;

public class ArticleListThread extends BaseThread {

	boolean _forceReload;
	
	@Override
	public void exec() {
		ThreadActivity act = (ThreadActivity)listener;		
		act.getProgressDTO().setProgressMessage(act.getString(R.string.Loading));
		act.run();
		act.getModel().load(_forceReload,(Context)listener);

		List<BbsArticleModel> list = act.getModel().getArticleModelList();
		for(int i=0;i<list.size();i++){
			act.getArticleQueue().add(list.get(i));
		}
		
		act.getProgressDTO().setProgressMessage(act.getString(R.string.LoadFinish));
		act.getProgressDTO().setProgress(ProgressDTO.COMPLETE);
	}
	
	public ArticleListThread(Handler handler,Runnable listener,boolean forceReload){
		super(handler,listener);
		_forceReload = forceReload;
	}

}
